﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：庄金冬 
    //
    // 文件名：BLL_Log.cs
    // 文件功能描述：日志业务逻辑类,实现接口IBLL_Log,继承自类MarshalByRefObject
    // 创建标识：庄金冬2009-03-06
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections.Generic;

using System.Text;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.DAL;
using HZ.Data;
namespace HZ.DrugTrade.BLL
{
    /// <summary>
    /// 日志业务逻辑类,实现接口IBLL_Log,继承自类MarshalByRefObject
    /// </summary>
    public class BLL_Log : MarshalByRefObject, IBLL_Log
    {
        private static BLL_Log _Instance = new BLL_Log();

        #region IBLL_Log 成员
        /// <summary>
        /// 条件查询日志[OrgID必须赋值]
        /// </summary>
        /// <remarks></remarks>
        /// <param name="user">查询用实体[Operator,OperateMessage,OperateTimeFrom,OperateTimeTo]</param>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">每页显示记录数</param>
        /// <param name="totalRecord">（输出参数）总记录数目</param>
        /// <returns></returns>
        public IList<KeyOperationLog> GetKeyOperationLogByWhere(KeyOperationLog operationLog, int currentPage, int pageSize, out int totalRecord)
        {
            totalRecord = 0;
            return DAL_Log.GetKeyOperationLogByWhere(operationLog, currentPage, pageSize, out totalRecord);
        }

        /// <summary>
        /// 添加日志(0,添加失败;1,添加成功;)
        /// </summary>
        /// <param name="user">日志对象（每个日志的Operator，OrgID必须赋值）</param>
        /// <returns>(0,添加失败;1,添加成功;)</returns>
        public int AddKeyOperationLog(KeyOperationLog keyOperationLog)
        {
            keyOperationLog.OperationLogSerialID = Guid.NewGuid().ToString();
            keyOperationLog.Operator = BLL_UserSession.GetCurrentUser().UserID;
            keyOperationLog.OrgID = BLL_UserSession.GetCurrentUser().Org.OrgID;
            keyOperationLog.OperateTime = DateTime.Now;
            keyOperationLog.ClientIP = HZ.Fun.GetClientIP();//记录日志的操作IP add by zdc 
            return HZ.Data.DAL_Helper.OperateTableSQL(keyOperationLog, HZ.Data.TableOperator.Insert);
        }
        /// <summary>
        /// 返回一个静态实例,由服务器端使用.
        /// </summary>
        public static BLL_Log Instance
        {
            get { return _Instance; }
        }
        #endregion
    }
}
